<?php
use yii\helpers\Url;
use yii\Web\View;
use app\assets\CreativeAsset;
CreativeAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  \Yii::t('creative', 'Creative'),
  \Yii::t('common', 'Data')
];
$jsMsgs = $this->context->loadJsMsgs([
  'table',
  'dialog',
  'listOp',
  'creative',
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('creative', 'Creative')?>
    <small><?=\Yii::t('creative', 'Creative List')?></small>
    <div class="btn-group btn-group-sm pull-right" role="group" aria-label="...">
      <div class="text-error btn hidden" id="all_tip">
        <?=\Yii::t('common', 'Please select the brand for add!')?>
      </div>
      <!-- <a href="<?= Url::to(['new-cpe-banner-creative']) ?>" class="btn btn-primary new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> <?= \Yii::t('common', 'Loading').'...' ?>" id="new-cpe-operate-btn">
        <i class="fa fa-plus-circle"></i>
        <?=\Yii::t('creative', 'New CPE Creative')?>
      </a> -->
  <?php
//     $loading = \Yii::t('common', 'Loading').'...';
//     $pcUrl = Url::to(['new-banner-creative', 'solution_id' => $solution_id]);
//     $pcCrt = \Yii::t('creative', 'New Display Creative');
//     $pcDiv = <<<FINE
//       <a href="$pcUrl" class="btn btn-success new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-banner-operate-btn">
//         <i class="fa fa-plus-circle"></i>
//         $pcCrt
//       </a>
// FINE;
//     if (in_array(1, $_SESSION['traffic_slot'])) echo $pcDiv;
   ?>
   <?php
//     $loading = \Yii::t('common', 'Loading').'...';
//     $pvUrl = Url::to(['new-video-creative', 'solution_id' => $solution_id]);
//     $pvCrt = \Yii::t('creative', 'New Video Creative');
//     $pvDiv = <<<FINE
//       <a href="$pvUrl" class="btn btn-primary new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-video-operate-btn">
//         <i class="fa fa-plus-circle"></i>
//         $pvCrt
//       </a>
// FINE;
//     if (in_array(2, $_SESSION['traffic_slot'])) echo $pvDiv;
   ?>
      <!-- <a href="<?= Url::to(['new-overlay-creative', 'solution_id' => $solution_id]);?>" class="btn btn-success new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> 加载中..." id="new-video-operate-btn">
        <i class="fa fa-plus-circle"></i>
        <?=\Yii::t('creative', 'New Overlay Creative')?>
      </a> -->
	  <?php
		$loading = \Yii::t('common', 'Loading').'...';
		$webUrl = Url::to(['new-web-creative', 'solution_id' => $solution_id]);
		$appUrl = Url::to(['new-app-creative', 'solution_id' => $solution_id]);
		$webCrt = \Yii::t('creative', 'New Wap Creative');
		$appCrt = \Yii::t('creative', 'New APP Creative');
		$mobDiv = <<<FINE
      <!--a href="$webUrl" class="btn btn-success new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-operate-btn">
        <i class="fa fa-plus-circle"></i>
        $webCrt
      </a -->
      <a href="$appUrl" class="btn btn-primary new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-video-operate-btn">
        <i class="fa fa-plus-circle"></i>
        $appCrt
      </a>
FINE;
		if (in_array(3, $_SESSION['traffic_slot'])) echo $mobDiv;
	 ?>
	  <?php
// 		$loading = \Yii::t('common', 'Loading').'...';
// 		$mvUrl = Url::to(['new-mobile-video-creative', 'solution_id' => $solution_id]);
// 		$mvCrt = \Yii::t('creative', 'New Mobile Video Creative');
// 		$mvDiv = <<<FINE
//       <a href="$mvUrl" class="btn btn-success new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-mobile-video-operate-btn">
//         <i class="fa fa-plus-circle"></i>
//         $mvCrt
//       </a>
// FINE;
// 		if (in_array(4, $_SESSION['traffic_slot'])) echo $mvDiv;
	 ?>
	 <?php
// 		$cUrl = Url::to(['new-custom-creative', 'solution_id' => $solution_id]);
// 		$cCrt = \Yii::t('creative', 'New Custom Creative');
// 	   $customDiv = <<<FINE
//       <a href="$cUrl" class="btn btn-primary new-operate-btn" data-loading-text="<i class='fa fa-spinner fa-spin'></i> $loading" id="new-custom-operate-btn">
//         <i class="fa fa-plus-circle"></i>
//         $cCrt
//       </a>
// FINE;
// 		if (in_array(1, $_SESSION['traffic_slot']) or in_array(3, $_SESSION['traffic_slot']) ) echo $customDiv;
	?>
    </div>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <input id="ckb-ids" type="hidden" value="" >
    <i class="fa fa-table"></i>
    <?=\Yii::t('creative', 'Creative List')?>
    <ul class="list-inline list-unstyled pull-right">
      <li>
        <a class="data-table-refresh" href="#" title="<?=\Yii::t('common', 'Click to refresh data')?>">
          <i class="fa fa-refresh"></i>
        </a>
      </li>
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div id="list-loading-wrap" class="local-loading-wrap"></div>
    <div class="table-responsive">
      <table class="table table-hover table-striped table-bordered table-condensed" id="data-table" data-tag="vm-adserver.creative-list">
        <thead class="heading">
          <tr>
            <th data-resizable-column-id="id" data-search="on" data-filter="on">ID</th>
            <th data-resizable-column-id="name" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Creative Name')?></th>
            <th data-resizable-column-id="strategy" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Solution')?></th>
            <th data-resizable-column-id="status" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Status')?></th>
            <!-- <th data-resizable-column-id="creativeType" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Type')?></th> -->
            <th data-resizable-column-id="materialType" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Material Type')?></th>
            <th data-resizable-column-id="creativeSize" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Size')?></th>
            <th class="tab-lg" data-resizable-column-id="vocation" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Vocation')?></th>
            <th data-resizable-column-id="cost" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Cost')?></th>
            <th data-resizable-column-id="showCount" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Shows')?></th>
            <th data-resizable-column-id="clickCount" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Clicks')?></th>
            <th data-resizable-column-id="clickRate" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Click Rate(%)')?></th>
            <!-- <th data-resizable-column-id="cpm" data-search="on" data-filter="on">CPM(￥)</th> -->
            <th data-resizable-column-id="cpc" data-search="on" data-filter="on">CPC(￥)</th>
            <th data-resizable-column-id="modifiedDate" data-search="on" data-filter="on"><?=\Yii::t('creative', 'Update Time')?></th>
            <th class="tab-op" data-resizable-column-id="operate" data-filter="on"><?=\Yii::t('creative', 'Actions')?></th>
          </tr>
        </thead>
        <tbody>
          <tr role="row">
            <td class="text-center dataTables_empty" colspan="14"><?=\Yii::t('site', 'No Records')?></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
<?php
  $strategyListUrl = yii::getAlias('@web').'/response/creative/strategyDataList.php';
  $strategyListUrl = Url::to(['get-creative-bind-solutions']);
  $dataUrl = Url::to(['get-creatives-list', 'solution_id' => $solution_id]);
  $webEditUrl = Url::to(['web-creative-edit']);
  $appEditUrl = Url::to(['app-creative-edit']);
  $bannerEditUrl = Url::to(['creative-edit']);
  $videoEditUrl = Url::to(['video-creative-edit']);
  $cpeEditUrl = Url::to(['cpe-banner-creative-edit']);
  $mobileVideoEditUrl = Url::to(['mobile-video-creative-edit']);
  $customEditUrl = Url::to(['custom-creative-edit']);
  $listPreviewWebOpUrl = Url::to(['mobile-creative-preview']);
  $listPreviewAppOpUrl = Url::to(['mobile-creative-preview']);
  $listPreviewCpeOpUrl = Url::to(['list-cpe-creative-preview']);
  $listPreviewBannerOpUrl = Url::to(['list-creative-preview']);
  $listPreviewVideoOpUrl = Url::to(['list-video-creative-preview']);
  $listPreviewMobileVideoOpUrl = Url::to(['list-mobile-video-creative-preview']);
  $listLinkOpUrl = Url::to(['list-operate-handle']);
  $listUnlinkOpUrl = Url::to(['list-operate-handle']);
  !$_SESSION['advertiser_id'] && $isAllBrand = true;
  $_SESSION['advertiser_id'] && $isAllBrand = false;
  $filter = $dataFilter;    // 需要屏蔽数据时 $dataFilter = ''， 显示数据 $dataFilter = true
  $this->registerJs("VAM.setVar('CLICK_FILTER_STATUS','$filter');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('STRATEGY_LIST_URL','$strategyListUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_WEB_EDIT_URL','$webEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_APP_EDIT_URL','$appEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_BANNER_EDIT_URL','$bannerEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_VIDEO_EDIT_URL','$videoEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_CPE_EDIT_URL','$cpeEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_MOBILE_VIDEO_EDIT_URL','$mobileVideoEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('DATA_CUSTOM_EDIT_URL','$customEditUrl');",View::POS_HEAD);
  $this->registerJs("VAM.setVar('CREATIVE_DATA_LIST','$dataUrl');", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_WEB_OP_URL','$listPreviewWebOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_APP_OP_URL','$listPreviewAppOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_BANNER_OP_URL','$listPreviewBannerOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_VIDEO_OP_URL','$listPreviewVideoOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_MOBILE_VIDEO_OP_URL','$listPreviewMobileVideoOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_PREVIEW_CPE_OP_URL','$listPreviewCpeOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_LINK_OP_URL', '$listLinkOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('LIST_UNLINK_OP_URL', '$listUnlinkOpUrl')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('IS_ALL_BRAND','$isAllBrand');",View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/creative/creativeList.js"]);
  });
</script>
